import request from "../utils/request";

interface GetCodeParams {
  tel: string;
}
interface UserAuthentication {
  userName: string;
  passWord: string;
  validCode: string;
}
interface LoginType {
  userName: string;
  passWord: string;
}

interface AuthAdmin {
  pageNum: number;
  pageSize: number;
}
interface userSetmenu {
  name: string;
  permissions: string;
  id: number;
}

interface userUpdate {
    name: string;
    permissions_id: number | string;
}

interface formType {
    active: number;
    age: number;
    avatar: string;
    id: number;
    mobile: string;
    name: string;
    sex: string;
}

interface companionListType {
    pageNum: string;
    pageSize: string;
}

interface companionDelete{
  id: string[];
}

// 发送验证码
export const getCode = (data: GetCodeParams) => {
  return request.post("/get/code", data);
};

// 验证码验证,注册用户
export const UserAuthentication = (data: UserAuthentication) => {
  return request.post("/user/authentication", data);
};

// 登录
export const Login = (data: LoginType) => {
  return request.post("/login", data);
};

//账号管理列表 get请求需要携带url上
export const getAuthAdmin = (params: AuthAdmin) => {
  return request.get("/auth/admin", { params });
};

// 菜单权限数据
export const userGetMenu = () => {
  return request.get("/user/getmenu");
};

// 权限修改 
export const userSetMenu = (data: userSetmenu) =>{
  return request.post("/user/setmenu", data);
}

// 菜单权限列表 
export const menuList = (params:AuthAdmin) => {
  return request.get("/menu/list", { params });
}

// 菜单权限下拉 
export const menuSelectlist = () => {
  return request.get("/menu/selectlist");
}

// 用户信息修改 
export const userUpdate = (data: userUpdate) =>{
  return request.post("/update/user", data);
}

// 用户菜单权限 
export const userMenuPermissions = () => {
  return request.get("/menu/permissions");
}

// 陪护师照片列表 
export const photoList = () => {
  return request.get("/photo/list");
}

// 陪护师创建 
export const companionCreate = (data: formType) => {
  return request.post("/companion", data);
}

//陪护师列表 
export const companionList = (params: companionListType) => {
  return request.get("/companion/list", { params });
}

// 陪护师删除 
export const companionDelete = (id: companionDelete) => {
  return request.post(`/delete/companion`, id);
}
